payload-richtext-tiptap 0.0.47 → 0.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.d.ts.map +1 -1
  2. package/dist/src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.js +21 -9
  3. package/dist/src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.js.map +1 -1
  4. package/dist/src/fields/TiptapEditor/extensions/Video/Video.d.ts +52 -0
  5. package/dist/src/fields/TiptapEditor/extensions/Video/Video.d.ts.map +1 -0
  6. package/dist/src/fields/TiptapEditor/extensions/Video/Video.js +81 -0
  7. package/dist/src/fields/TiptapEditor/extensions/Video/Video.js.map +1 -0
  8. package/dist/src/fields/TiptapEditor/extensions/Video/index.d.ts +2 -0
  9. package/dist/src/fields/TiptapEditor/extensions/Video/index.d.ts.map +1 -0
  10. package/dist/src/fields/TiptapEditor/extensions/Video/index.js +3 -0
  11. package/dist/src/fields/TiptapEditor/extensions/Video/index.js.map +1 -0
  12. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.d.ts +21 -0
  13. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.d.ts.map +1 -0
  14. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.js +97 -0
  15. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.js.map +1 -0
  16. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.d.ts +5 -0
  17. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.d.ts.map +1 -0
  18. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.js +133 -0
  19. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.js.map +1 -0
  20. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.d.ts +16 -0
  21. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.d.ts.map +1 -0
  22. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.js +39 -0
  23. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.js.map +1 -0
  24. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockWidth.d.ts +7 -0
  25. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockWidth.d.ts.map +1 -0
  26. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockWidth.js +39 -0
  27. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockWidth.js.map +1 -0
  28. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/index.d.ts +2 -0
  29. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/index.d.ts.map +1 -0
  30. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/index.js +3 -0
  31. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/index.js.map +1 -0
  32. package/dist/src/fields/TiptapEditor/extensions/extension-kit.d.ts.map +1 -1
  33. package/dist/src/fields/TiptapEditor/extensions/extension-kit.js +4 -3
  34. package/dist/src/fields/TiptapEditor/extensions/extension-kit.js.map +1 -1
  35. package/dist/src/fields/TiptapEditor/extensions/index.d.ts +1 -0
  36. package/dist/src/fields/TiptapEditor/extensions/index.d.ts.map +1 -1
  37. package/dist/src/fields/TiptapEditor/extensions/index.js +1 -0
  38. package/dist/src/fields/TiptapEditor/extensions/index.js.map +1 -1
  39. package/dist/src/fields/TiptapEditor/lib/extract.js +0 -1
  40. package/dist/src/fields/TiptapEditor/lib/extract.js.map +1 -1
  41. package/dist/src/fields/TiptapEditor/types.d.js.map +1 -1
  42. package/dist/src/styles.css +2 -28
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,eAAO,MAAM,kBAAkB,uBAAwB,eAAe,2BAIjE;IACD,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,gCAiEF,CAAC"}
1
+ {"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AAExD,OAAO,EAEL,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAC1C,eAAO,MAAM,kBAAkB,uBAAwB,eAAe,2BAIjE;IACD,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,gCA4EF,CAAC"}
@@ -3,14 +3,26 @@ import { NodeViewWrapper } from "@tiptap/react";
3
3
  import { useCallback } from "react";
4
4
  export const ImageUploadBuilder = (openAssetHQHandler)=>{
5
5
  const ImageUpload = ({ getPos, editor })=>{
6
- const onUpload = useCallback((url)=>{
7
- if (url) {
8
- editor.chain().focus().setImageBlock({
9
- src: url
10
- }).deleteRange({
11
- from: getPos(),
12
- to: getPos()
13
- }).focus().run();
6
+ const onUpload = useCallback((asset)=>{
7
+ if (asset) {
8
+ console.log("asset in ImageUpload itself:", asset);
9
+ if (asset.type === "IMAGE") {
10
+ editor.chain().focus().setImageBlock({
11
+ src: asset.fullUrl
12
+ }) //TODO: should also set other fields to data-media-id ... it'd be easier to later find which media id is this.
13
+ .deleteRange({
14
+ from: getPos(),
15
+ to: getPos()
16
+ }).focus().run();
17
+ } else {
18
+ editor.chain().focus().setVideoBlock({
19
+ src: asset.videoUrl,
20
+ poster: asset.fullUrl
21
+ }).deleteRange({
22
+ from: getPos(),
23
+ to: getPos()
24
+ }).focus().run();
25
+ }
14
26
  }
15
27
  }, [
16
28
  getPos,
@@ -33,7 +45,7 @@ export const ImageUploadBuilder = (openAssetHQHandler)=>{
33
45
  e.preventDefault();
34
46
  openAssetHQHandler(onUpload);
35
47
  },
36
- children: "Upload Image"
48
+ children: "Select an asset"
37
49
  })
38
50
  })
39
51
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"sourcesContent":["import { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport { useCallback } from \"react\";\nimport { openAssetHQType } from \"src/fields/TiptapEditor/types.js\";\nexport const ImageUploadBuilder = (openAssetHQHandler: openAssetHQType) => {\n const ImageUpload = ({\n getPos,\n editor,\n }: {\n getPos: () => number;\n editor: Editor;\n }) => {\n const onUpload = useCallback(\n (url: string) => {\n if (url) {\n editor\n .chain()\n .focus()\n .setImageBlock({ src: url })\n .deleteRange({ from: getPos(), to: getPos() })\n .focus()\n .run();\n }\n },\n [getPos, editor]\n );\n\n return (\n <NodeViewWrapper>\n <div className=\"p-0 m-0\" data-drag-handle>\n {/* <RenderFields\n fieldMap={[\n {\n name: \"media\",\n type: \"upload\",\n cellComponentProps: {\n name: \"media\",\n schemaPath: \"media\",\n },\n fieldComponentProps: {},\n fieldIsPresentational: true,\n isFieldAffectingData: false,\n localized: false,\n },\n ]}\n path=\"media\"\n readOnly={false}\n schemaPath=\"\"\n // fieldTypes={fieldTypes}\n // fields={sidebarFields}\n // permissions={permissions.fields}\n // readOnly={!hasSavePermission}\n /> */}\n <a\n href=\"#\"\n style={{\n padding: 5,\n borderRadius: 5,\n backgroundColor: \"blue\",\n color: \"white\",\n cursor: \"pointer\",\n }}\n onClick={(e) => {\n e.preventDefault();\n openAssetHQHandler(onUpload);\n }}\n >\n Upload Image\n </a>\n {/* <ImageUploader onUpload={onUpload} /> */}\n </div>\n </NodeViewWrapper>\n );\n };\n\n return ImageUpload;\n};\n"],"names":["NodeViewWrapper","useCallback","ImageUploadBuilder","openAssetHQHandler","ImageUpload","getPos","editor","onUpload","url","chain","focus","setImageBlock","src","deleteRange","from","to","run","div","className","data-drag-handle","a","href","style","padding","borderRadius","backgroundColor","color","cursor","onClick","e","preventDefault"],"mappings":";AAAA,SAAiBA,eAAe,QAAQ,gBAAgB;AACxD,SAASC,WAAW,QAAQ,QAAQ;AAEpC,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAMC,cAAc,CAAC,EACnBC,MAAM,EACNC,MAAM,EAIP;QACC,MAAMC,WAAWN,YACf,CAACO;YACC,IAAIA,KAAK;gBACPF,OACGG,KAAK,GACLC,KAAK,GACLC,aAAa,CAAC;oBAAEC,KAAKJ;gBAAI,GACzBK,WAAW,CAAC;oBAAEC,MAAMT;oBAAUU,IAAIV;gBAAS,GAC3CK,KAAK,GACLM,GAAG;YACR;QACF,GACA;YAACX;YAAQC;SAAO;QAGlB,qBACE,KAACN;sBACC,cAAA,KAACiB;gBAAIC,WAAU;gBAAUC,kBAAgB;0BAwBvC,cAAA,KAACC;oBACCC,MAAK;oBACLC,OAAO;wBACLC,SAAS;wBACTC,cAAc;wBACdC,iBAAiB;wBACjBC,OAAO;wBACPC,QAAQ;oBACV;oBACAC,SAAS,CAACC;wBACRA,EAAEC,cAAc;wBAChB3B,mBAAmBI;oBACrB;8BACD;;;;IAOT;IAEA,OAAOH;AACT,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"sourcesContent":["import { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport { useCallback } from \"react\";\nimport {\n AssetReturnType,\n openAssetHQType,\n} from \"src/fields/TiptapEditor/types.js\";\nexport const ImageUploadBuilder = (openAssetHQHandler: openAssetHQType) => {\n const ImageUpload = ({\n getPos,\n editor,\n }: {\n getPos: () => number;\n editor: Editor;\n }) => {\n const onUpload = useCallback(\n (asset: AssetReturnType) => {\n if (asset) {\n console.log(\"asset in ImageUpload itself:\", asset);\n if (asset.type === \"IMAGE\") {\n editor\n .chain()\n .focus()\n .setImageBlock({ src: asset.fullUrl }) //TODO: should also set other fields to data-media-id ... it'd be easier to later find which media id is this.\n .deleteRange({ from: getPos(), to: getPos() })\n .focus()\n .run();\n } else {\n editor\n .chain()\n .focus()\n .setVideoBlock({ src: asset.videoUrl, poster: asset.fullUrl })\n .deleteRange({ from: getPos(), to: getPos() })\n .focus()\n .run();\n }\n }\n },\n [getPos, editor]\n );\n\n return (\n <NodeViewWrapper>\n <div className=\"p-0 m-0\" data-drag-handle>\n {/* <RenderFields\n fieldMap={[\n {\n name: \"media\",\n type: \"upload\",\n cellComponentProps: {\n name: \"media\",\n schemaPath: \"media\",\n },\n fieldComponentProps: {},\n fieldIsPresentational: true,\n isFieldAffectingData: false,\n localized: false,\n },\n ]}\n path=\"media\"\n readOnly={false}\n schemaPath=\"\"\n // fieldTypes={fieldTypes}\n // fields={sidebarFields}\n // permissions={permissions.fields}\n // readOnly={!hasSavePermission}\n /> */}\n <a\n href=\"#\"\n style={{\n padding: 5,\n borderRadius: 5,\n backgroundColor: \"blue\",\n color: \"white\",\n cursor: \"pointer\",\n }}\n onClick={(e) => {\n e.preventDefault();\n openAssetHQHandler(onUpload);\n }}\n >\n Select an asset\n </a>\n {/* <ImageUploader onUpload={onUpload} /> */}\n </div>\n </NodeViewWrapper>\n );\n };\n\n return ImageUpload;\n};\n"],"names":["NodeViewWrapper","useCallback","ImageUploadBuilder","openAssetHQHandler","ImageUpload","getPos","editor","onUpload","asset","console","log","type","chain","focus","setImageBlock","src","fullUrl","deleteRange","from","to","run","setVideoBlock","videoUrl","poster","div","className","data-drag-handle","a","href","style","padding","borderRadius","backgroundColor","color","cursor","onClick","e","preventDefault"],"mappings":";AAAA,SAAiBA,eAAe,QAAQ,gBAAgB;AACxD,SAASC,WAAW,QAAQ,QAAQ;AAKpC,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAMC,cAAc,CAAC,EACnBC,MAAM,EACNC,MAAM,EAIP;QACC,MAAMC,WAAWN,YACf,CAACO;YACC,IAAIA,OAAO;gBACTC,QAAQC,GAAG,CAAC,gCAAgCF;gBAC5C,IAAIA,MAAMG,IAAI,KAAK,SAAS;oBAC1BL,OACGM,KAAK,GACLC,KAAK,GACLC,aAAa,CAAC;wBAAEC,KAAKP,MAAMQ,OAAO;oBAAC,GAAG,8GAA8G;qBACpJC,WAAW,CAAC;wBAAEC,MAAMb;wBAAUc,IAAId;oBAAS,GAC3CQ,KAAK,GACLO,GAAG;gBACR,OAAO;oBACLd,OACGM,KAAK,GACLC,KAAK,GACLQ,aAAa,CAAC;wBAAEN,KAAKP,MAAMc,QAAQ;wBAAEC,QAAQf,MAAMQ,OAAO;oBAAC,GAC3DC,WAAW,CAAC;wBAAEC,MAAMb;wBAAUc,IAAId;oBAAS,GAC3CQ,KAAK,GACLO,GAAG;gBACR;YACF;QACF,GACA;YAACf;YAAQC;SAAO;QAGlB,qBACE,KAACN;sBACC,cAAA,KAACwB;gBAAIC,WAAU;gBAAUC,kBAAgB;0BAwBvC,cAAA,KAACC;oBACCC,MAAK;oBACLC,OAAO;wBACLC,SAAS;wBACTC,cAAc;wBACdC,iBAAiB;wBACjBC,OAAO;wBACPC,QAAQ;oBACV;oBACAC,SAAS,CAACC;wBACRA,EAAEC,cAAc;wBAChBlC,mBAAmBI;oBACrB;8BACD;;;;IAOT;IAEA,OAAOH;AACT,EAAE"}
@@ -0,0 +1,52 @@
1
+ import { Node } from "@tiptap/core";
2
+ export interface VideoOptions {
3
+ /**
4
+ * Controls if the image node should be inline or not.
5
+ * @default false
6
+ * @example true
7
+ */
8
+ inline: boolean;
9
+ /**
10
+ * Controls if base64 images are allowed. Enable this if you want to allow
11
+ * base64 image urls in the `src` attribute.
12
+ * @default false
13
+ * @example true
14
+ */
15
+ allowBase64: boolean;
16
+ /**
17
+ * HTML attributes to add to the image element.
18
+ * @default {}
19
+ * @example { class: 'foo' }
20
+ */
21
+ HTMLAttributes: Record<string, any>;
22
+ }
23
+ declare module "@tiptap/core" {
24
+ interface Commands<ReturnType> {
25
+ video: {
26
+ /**
27
+ * Add an image
28
+ * @param options The image attributes
29
+ * @example
30
+ * editor
31
+ * .commands
32
+ * .setVideo({ src: 'https://tiptap.dev/logo.png', alt: 'tiptap', title: 'tiptap logo' })
33
+ */
34
+ setVideo: (options: {
35
+ src: string;
36
+ alt?: string;
37
+ title?: string;
38
+ poster?: string;
39
+ }) => ReturnType;
40
+ };
41
+ }
42
+ }
43
+ /**
44
+ * Matches an image to a ![image](src "title") on input.
45
+ */
46
+ export declare const inputRegex: RegExp;
47
+ /**
48
+ * This extension allows you to insert images.
49
+ * @see https://www.tiptap.dev/api/nodes/image
50
+ */
51
+ export declare const Video: Node<VideoOptions, any>;
52
+ //# sourceMappingURL=Video.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Video.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/Video/Video.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAiB,MAAM,cAAc,CAAC;AAEpE,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;;;;OAKG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACrC;AAED,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,KAAK,EAAE;YACL;;;;;;;eAOG;YACH,QAAQ,EAAE,CAAC,OAAO,EAAE;gBAClB,GAAG,EAAE,MAAM,CAAC;gBACZ,GAAG,CAAC,EAAE,MAAM,CAAC;gBACb,KAAK,CAAC,EAAE,MAAM,CAAC;gBACf,MAAM,CAAC,EAAE,MAAM,CAAC;aACjB,KAAK,UAAU,CAAC;SAClB,CAAC;KACH;CACF;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,QACqC,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,KAAK,yBAiFhB,CAAC"}
@@ -0,0 +1,81 @@
1
+ import { mergeAttributes, Node, nodeInputRule } from "@tiptap/core";
2
+ /**
3
+ * Matches an image to a ![image](src "title") on input.
4
+ */ export const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
5
+ /**
6
+ * This extension allows you to insert images.
7
+ * @see https://www.tiptap.dev/api/nodes/image
8
+ */ export const Video = Node.create({
9
+ name: "video",
10
+ addOptions () {
11
+ return {
12
+ inline: false,
13
+ allowBase64: false,
14
+ HTMLAttributes: {}
15
+ };
16
+ },
17
+ inline () {
18
+ return this.options.inline;
19
+ },
20
+ group () {
21
+ return this.options.inline ? "inline" : "block";
22
+ },
23
+ draggable: true,
24
+ addAttributes () {
25
+ return {
26
+ src: {
27
+ default: null
28
+ },
29
+ alt: {
30
+ default: null
31
+ },
32
+ title: {
33
+ default: null
34
+ },
35
+ poster: {
36
+ default: null
37
+ }
38
+ };
39
+ },
40
+ parseHTML () {
41
+ return [
42
+ {
43
+ tag: this.options.allowBase64 ? "video[src]" : 'video[src]:not([src^="data:"])'
44
+ }
45
+ ];
46
+ },
47
+ renderHTML ({ HTMLAttributes }) {
48
+ return [
49
+ "video",
50
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)
51
+ ];
52
+ },
53
+ addCommands () {
54
+ return {
55
+ setVideo: (options)=>({ commands })=>{
56
+ return commands.insertContent({
57
+ type: this.name,
58
+ attrs: options
59
+ });
60
+ }
61
+ };
62
+ },
63
+ addInputRules () {
64
+ return [
65
+ nodeInputRule({
66
+ find: inputRegex,
67
+ type: this.type,
68
+ getAttributes: (match)=>{
69
+ const [, , alt, src, title] = match;
70
+ return {
71
+ src,
72
+ alt,
73
+ title
74
+ };
75
+ }
76
+ })
77
+ ];
78
+ }
79
+ });
80
+
81
+ //# sourceMappingURL=Video.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/Video/Video.ts"],"sourcesContent":["import { mergeAttributes, Node, nodeInputRule } from \"@tiptap/core\";\n\nexport interface VideoOptions {\n /**\n * Controls if the image node should be inline or not.\n * @default false\n * @example true\n */\n inline: boolean;\n\n /**\n * Controls if base64 images are allowed. Enable this if you want to allow\n * base64 image urls in the `src` attribute.\n * @default false\n * @example true\n */\n allowBase64: boolean;\n\n /**\n * HTML attributes to add to the image element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>;\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n video: {\n /**\n * Add an image\n * @param options The image attributes\n * @example\n * editor\n * .commands\n * .setVideo({ src: 'https://tiptap.dev/logo.png', alt: 'tiptap', title: 'tiptap logo' })\n */\n setVideo: (options: {\n src: string;\n alt?: string;\n title?: string;\n poster?: string;\n }) => ReturnType;\n };\n }\n}\n\n/**\n * Matches an image to a ![image](src \"title\") on input.\n */\nexport const inputRegex =\n /(?:^|\\s)(!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\))$/;\n\n/**\n * This extension allows you to insert images.\n * @see https://www.tiptap.dev/api/nodes/image\n */\nexport const Video = Node.create<VideoOptions>({\n name: \"video\",\n\n addOptions() {\n return {\n inline: false,\n allowBase64: false,\n HTMLAttributes: {},\n };\n },\n\n inline() {\n return this.options.inline;\n },\n\n group() {\n return this.options.inline ? \"inline\" : \"block\";\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n title: {\n default: null,\n },\n poster: {\n default: null,\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: this.options.allowBase64\n ? \"video[src]\"\n : 'video[src]:not([src^=\"data:\"])',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"video\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n ];\n },\n\n addCommands() {\n return {\n setVideo:\n (options) =>\n ({ commands }) => {\n return commands.insertContent({\n type: this.name,\n attrs: options,\n });\n },\n };\n },\n\n addInputRules() {\n return [\n nodeInputRule({\n find: inputRegex,\n type: this.type,\n getAttributes: (match) => {\n const [, , alt, src, title] = match;\n\n return { src, alt, title };\n },\n }),\n ];\n },\n});\n"],"names":["mergeAttributes","Node","nodeInputRule","inputRegex","Video","create","name","addOptions","inline","allowBase64","HTMLAttributes","options","group","draggable","addAttributes","src","default","alt","title","poster","parseHTML","tag","renderHTML","addCommands","setVideo","commands","insertContent","type","attrs","addInputRules","find","getAttributes","match"],"mappings":"AAAA,SAASA,eAAe,EAAEC,IAAI,EAAEC,aAAa,QAAQ,eAAe;AA+CpE;;CAEC,GACD,OAAO,MAAMC,aACX,2DAA2D;AAE7D;;;CAGC,GACD,OAAO,MAAMC,QAAQH,KAAKI,MAAM,CAAe;IAC7CC,MAAM;IAENC;QACE,OAAO;YACLC,QAAQ;YACRC,aAAa;YACbC,gBAAgB,CAAC;QACnB;IACF;IAEAF;QACE,OAAO,IAAI,CAACG,OAAO,CAACH,MAAM;IAC5B;IAEAI;QACE,OAAO,IAAI,CAACD,OAAO,CAACH,MAAM,GAAG,WAAW;IAC1C;IAEAK,WAAW;IAEXC;QACE,OAAO;YACLC,KAAK;gBACHC,SAAS;YACX;YACAC,KAAK;gBACHD,SAAS;YACX;YACAE,OAAO;gBACLF,SAAS;YACX;YACAG,QAAQ;gBACNH,SAAS;YACX;QACF;IACF;IAEAI;QACE,OAAO;YACL;gBACEC,KAAK,IAAI,CAACV,OAAO,CAACF,WAAW,GACzB,eACA;YACN;SACD;IACH;IAEAa,YAAW,EAAEZ,cAAc,EAAE;QAC3B,OAAO;YACL;YACAV,gBAAgB,IAAI,CAACW,OAAO,CAACD,cAAc,EAAEA;SAC9C;IACH;IAEAa;QACE,OAAO;YACLC,UACE,CAACb,UACD,CAAC,EAAEc,QAAQ,EAAE;oBACX,OAAOA,SAASC,aAAa,CAAC;wBAC5BC,MAAM,IAAI,CAACrB,IAAI;wBACfsB,OAAOjB;oBACT;gBACF;QACJ;IACF;IAEAkB;QACE,OAAO;YACL3B,cAAc;gBACZ4B,MAAM3B;gBACNwB,MAAM,IAAI,CAACA,IAAI;gBACfI,eAAe,CAACC;oBACd,MAAM,KAAKf,KAAKF,KAAKG,MAAM,GAAGc;oBAE9B,OAAO;wBAAEjB;wBAAKE;wBAAKC;oBAAM;gBAC3B;YACF;SACD;IACH;AACF,GAAG"}
@@ -0,0 +1,2 @@
1
+ export * from "./Video.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/Video/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./Video.js";
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/Video/index.ts"],"sourcesContent":["export * from \"./Video.js\";\n"],"names":[],"mappings":"AAAA,cAAc,aAAa"}
@@ -0,0 +1,21 @@
1
+ import { Range } from "@tiptap/core";
2
+ declare module "@tiptap/core" {
3
+ interface Commands<ReturnType> {
4
+ videoBlock: {
5
+ setVideoBlock: (attributes: {
6
+ src: string;
7
+ poster: string;
8
+ }) => ReturnType;
9
+ setVideoBlockAt: (attributes: {
10
+ src: string;
11
+ poster: string;
12
+ pos: number | Range;
13
+ }) => ReturnType;
14
+ setVideoBlockAlign: (align: "left" | "center" | "right") => ReturnType;
15
+ setVideoBlockWidth: (width: number) => ReturnType;
16
+ };
17
+ }
18
+ }
19
+ export declare const VideoBlock: import("@tiptap/react").Node<import("../Video/Video.js").VideoOptions, any>;
20
+ export default VideoBlock;
21
+ //# sourceMappingURL=VideoBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VideoBlock.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,EAAE,MAAM,cAAc,CAAC;AAKtD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,UAAU,EAAE;YACV,aAAa,EAAE,CAAC,UAAU,EAAE;gBAC1B,GAAG,EAAE,MAAM,CAAC;gBACZ,MAAM,EAAE,MAAM,CAAC;aAChB,KAAK,UAAU,CAAC;YACjB,eAAe,EAAE,CAAC,UAAU,EAAE;gBAC5B,GAAG,EAAE,MAAM,CAAC;gBACZ,MAAM,EAAE,MAAM,CAAC;gBACf,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;aACrB,KAAK,UAAU,CAAC;YACjB,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,KAAK,UAAU,CAAC;YACvE,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,UAAU,CAAC;SACnD,CAAC;KACH;CACF;AAED,eAAO,MAAM,UAAU,6EAqGrB,CAAC;AAEH,eAAe,UAAU,CAAC"}
@@ -0,0 +1,97 @@
1
+ "use client";
2
+ import { ReactNodeViewRenderer } from "@tiptap/react";
3
+ import { mergeAttributes } from "@tiptap/core";
4
+ import { VideoBlockView } from "./components/VideoBlockView.js";
5
+ import { Video } from "../Video/Video.js";
6
+ export const VideoBlock = Video.extend({
7
+ name: "videoBlock",
8
+ group: "block",
9
+ defining: true,
10
+ isolating: true,
11
+ addAttributes () {
12
+ return {
13
+ src: {
14
+ default: "",
15
+ parseHTML: (element)=>element.getAttribute("src"),
16
+ renderHTML: (attributes)=>({
17
+ src: attributes.src
18
+ })
19
+ },
20
+ poster: {
21
+ default: "",
22
+ parseHTML: (element)=>element.getAttribute("poster"),
23
+ renderHTML: (attributes)=>({
24
+ poster: attributes.poster
25
+ })
26
+ },
27
+ width: {
28
+ default: "100%",
29
+ parseHTML: (element)=>element.getAttribute("data-width"),
30
+ renderHTML: (attributes)=>({
31
+ "data-width": attributes.width
32
+ })
33
+ },
34
+ align: {
35
+ default: "center",
36
+ parseHTML: (element)=>element.getAttribute("data-align"),
37
+ renderHTML: (attributes)=>({
38
+ "data-align": attributes.align
39
+ })
40
+ },
41
+ alt: {
42
+ default: undefined,
43
+ parseHTML: (element)=>element.getAttribute("alt"),
44
+ renderHTML: (attributes)=>({
45
+ alt: attributes.alt
46
+ })
47
+ }
48
+ };
49
+ },
50
+ parseHTML () {
51
+ return [
52
+ {
53
+ tag: 'video[src*="tiptap.dev"]:not([src^="data:"]), video[src*="windows.net"]:not([src^="data:"])'
54
+ }
55
+ ];
56
+ },
57
+ renderHTML ({ HTMLAttributes }) {
58
+ return [
59
+ "video",
60
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)
61
+ ];
62
+ },
63
+ addCommands () {
64
+ return {
65
+ setVideoBlock: (attrs)=>({ commands })=>{
66
+ return commands.insertContent({
67
+ type: "videoBlock",
68
+ attrs: {
69
+ src: attrs.src,
70
+ poster: attrs.poster
71
+ }
72
+ });
73
+ },
74
+ setVideoBlockAt: (attrs)=>({ commands })=>{
75
+ return commands.insertContentAt(attrs.pos, {
76
+ type: "videoBlock",
77
+ attrs: {
78
+ src: attrs.src,
79
+ poster: attrs.poster
80
+ }
81
+ });
82
+ },
83
+ setVideoBlockAlign: (align)=>({ commands })=>commands.updateAttributes("videoBlock", {
84
+ align
85
+ }),
86
+ setVideoBlockWidth: (width)=>({ commands })=>commands.updateAttributes("videoBlock", {
87
+ width: `${Math.max(0, Math.min(100, width))}%`
88
+ })
89
+ };
90
+ },
91
+ addNodeView () {
92
+ return ReactNodeViewRenderer(VideoBlockView);
93
+ }
94
+ });
95
+ export default VideoBlock;
96
+
97
+ //# sourceMappingURL=VideoBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.ts"],"sourcesContent":["\"use client\";\n\nimport { ReactNodeViewRenderer } from \"@tiptap/react\";\nimport { mergeAttributes, Range } from \"@tiptap/core\";\n\nimport { VideoBlockView } from \"./components/VideoBlockView.js\";\nimport { Video } from \"../Video/Video.js\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n videoBlock: {\n setVideoBlock: (attributes: {\n src: string;\n poster: string;\n }) => ReturnType;\n setVideoBlockAt: (attributes: {\n src: string;\n poster: string;\n pos: number | Range;\n }) => ReturnType;\n setVideoBlockAlign: (align: \"left\" | \"center\" | \"right\") => ReturnType;\n setVideoBlockWidth: (width: number) => ReturnType;\n };\n }\n}\n\nexport const VideoBlock = Video.extend({\n name: \"videoBlock\",\n\n group: \"block\",\n\n defining: true,\n\n isolating: true,\n\n addAttributes() {\n return {\n src: {\n default: \"\",\n parseHTML: (element) => element.getAttribute(\"src\"),\n renderHTML: (attributes) => ({\n src: attributes.src,\n }),\n },\n poster: {\n default: \"\",\n parseHTML: (element) => element.getAttribute(\"poster\"),\n renderHTML: (attributes) => ({\n poster: attributes.poster,\n }),\n },\n width: {\n default: \"100%\",\n parseHTML: (element) => element.getAttribute(\"data-width\"),\n renderHTML: (attributes) => ({\n \"data-width\": attributes.width,\n }),\n },\n align: {\n default: \"center\",\n parseHTML: (element) => element.getAttribute(\"data-align\"),\n renderHTML: (attributes) => ({\n \"data-align\": attributes.align,\n }),\n },\n alt: {\n default: undefined,\n parseHTML: (element) => element.getAttribute(\"alt\"),\n renderHTML: (attributes) => ({\n alt: attributes.alt,\n }),\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'video[src*=\"tiptap.dev\"]:not([src^=\"data:\"]), video[src*=\"windows.net\"]:not([src^=\"data:\"])',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"video\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n ];\n },\n\n addCommands() {\n return {\n setVideoBlock:\n (attrs) =>\n ({ commands }) => {\n return commands.insertContent({\n type: \"videoBlock\",\n attrs: { src: attrs.src, poster: attrs.poster },\n });\n },\n\n setVideoBlockAt:\n (attrs) =>\n ({ commands }) => {\n return commands.insertContentAt(attrs.pos, {\n type: \"videoBlock\",\n attrs: { src: attrs.src, poster: attrs.poster },\n });\n },\n\n setVideoBlockAlign:\n (align) =>\n ({ commands }) =>\n commands.updateAttributes(\"videoBlock\", { align }),\n\n setVideoBlockWidth:\n (width) =>\n ({ commands }) =>\n commands.updateAttributes(\"videoBlock\", {\n width: `${Math.max(0, Math.min(100, width))}%`,\n }),\n };\n },\n\n addNodeView() {\n return ReactNodeViewRenderer(VideoBlockView);\n },\n});\n\nexport default VideoBlock;\n"],"names":["ReactNodeViewRenderer","mergeAttributes","VideoBlockView","Video","VideoBlock","extend","name","group","defining","isolating","addAttributes","src","default","parseHTML","element","getAttribute","renderHTML","attributes","poster","width","align","alt","undefined","tag","HTMLAttributes","options","addCommands","setVideoBlock","attrs","commands","insertContent","type","setVideoBlockAt","insertContentAt","pos","setVideoBlockAlign","updateAttributes","setVideoBlockWidth","Math","max","min","addNodeView"],"mappings":"AAAA;AAEA,SAASA,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,eAAe,QAAe,eAAe;AAEtD,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,KAAK,QAAQ,oBAAoB;AAoB1C,OAAO,MAAMC,aAAaD,MAAME,MAAM,CAAC;IACrCC,MAAM;IAENC,OAAO;IAEPC,UAAU;IAEVC,WAAW;IAEXC;QACE,OAAO;YACLC,KAAK;gBACHC,SAAS;gBACTC,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7CC,YAAY,CAACC,aAAgB,CAAA;wBAC3BN,KAAKM,WAAWN,GAAG;oBACrB,CAAA;YACF;YACAO,QAAQ;gBACNN,SAAS;gBACTC,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7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AAM;YAEpDiB,oBACE,CAAClB,QACD,CAAC,EAAEU,QAAQ,EAAE,GACXA,SAASO,gBAAgB,CAAC,cAAc;wBACtCjB,OAAO,CAAC,EAAEmB,KAAKC,GAAG,CAAC,GAAGD,KAAKE,GAAG,CAAC,KAAKrB,QAAQ,CAAC,CAAC;oBAChD;QACN;IACF;IAEAsB;QACE,OAAOzC,sBAAsBE;IAC/B;AACF,GAAG;AAEH,eAAeE,WAAW"}
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from "react";
2
+ import { MenuProps } from "../../../features/menus/types.js";
3
+ export declare const VideoBlockMenu: ({ editor, appendTo }: MenuProps) => ReactNode;
4
+ export default VideoBlockMenu;
5
+ //# sourceMappingURL=VideoBlockMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VideoBlockMenu.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AASvD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAM7D,eAAO,MAAM,cAAc,yBAA0B,SAAS,KAAG,SA6GhE,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,133 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react";
3
+ import { useCallback, useRef } from "react";
4
+ import { sticky } from "tippy.js";
5
+ import { v4 as uuid } from "uuid";
6
+ import { AlignHorizontalDistributeCenter, AlignHorizontalDistributeEnd, AlignHorizontalDistributeStart } from "lucide-react";
7
+ import { Icon } from "../../../features/ui/Icon.js";
8
+ import { Toolbar } from "../../../features/ui/Toolbar.js";
9
+ import { getRenderContainer } from "../../../lib/utils/index.js";
10
+ import { VideoBlockWidth } from "./VideoBlockWidth.js";
11
+ export const VideoBlockMenu = ({ editor, appendTo })=>{
12
+ const menuRef = useRef(null);
13
+ const tippyInstance = useRef(null);
14
+ const getReferenceClientRect = useCallback(()=>{
15
+ const renderContainer = getRenderContainer(editor, "node-videoBlock");
16
+ const rect = renderContainer?.getBoundingClientRect() || new DOMRect(-1000, -1000, 0, 0);
17
+ return rect;
18
+ }, [
19
+ editor
20
+ ]);
21
+ const shouldShow = useCallback(()=>{
22
+ const isActive = editor.isActive("videoBlock");
23
+ return isActive;
24
+ }, [
25
+ editor
26
+ ]);
27
+ const onAlignVideoLeft = useCallback(()=>{
28
+ editor.chain().focus(undefined, {
29
+ scrollIntoView: false
30
+ }).setVideoBlockAlign("left").run();
31
+ }, [
32
+ editor
33
+ ]);
34
+ const onAlignVideoCenter = useCallback(()=>{
35
+ editor.chain().focus(undefined, {
36
+ scrollIntoView: false
37
+ }).setVideoBlockAlign("center").run();
38
+ }, [
39
+ editor
40
+ ]);
41
+ const onAlignVideoRight = useCallback(()=>{
42
+ editor.chain().focus(undefined, {
43
+ scrollIntoView: false
44
+ }).setVideoBlockAlign("right").run();
45
+ }, [
46
+ editor
47
+ ]);
48
+ const onWidthChange = useCallback((value)=>{
49
+ editor.chain().focus(undefined, {
50
+ scrollIntoView: false
51
+ }).setVideoBlockWidth(value).run();
52
+ }, [
53
+ editor
54
+ ]);
55
+ return /*#__PURE__*/ _jsx(BaseBubbleMenu, {
56
+ editor: editor,
57
+ pluginKey: `videoBlockMenu-${uuid()}`,
58
+ shouldShow: shouldShow,
59
+ updateDelay: 0,
60
+ tippyOptions: {
61
+ offset: [
62
+ 0,
63
+ 8
64
+ ],
65
+ popperOptions: {
66
+ modifiers: [
67
+ {
68
+ name: "flip",
69
+ enabled: false
70
+ }
71
+ ]
72
+ },
73
+ getReferenceClientRect,
74
+ onCreate: (instance)=>{
75
+ tippyInstance.current = instance;
76
+ },
77
+ appendTo: ()=>{
78
+ return appendTo?.current;
79
+ },
80
+ plugins: [
81
+ sticky
82
+ ],
83
+ sticky: "popper"
84
+ },
85
+ children: /*#__PURE__*/ _jsxs(Toolbar.Wrapper, {
86
+ shouldShowContent: shouldShow(),
87
+ ref: menuRef,
88
+ children: [
89
+ /*#__PURE__*/ _jsx(Toolbar.Button, {
90
+ type: "button",
91
+ tooltip: "Align video left",
92
+ active: editor.isActive("videoBlock", {
93
+ align: "left"
94
+ }),
95
+ onClick: onAlignVideoLeft,
96
+ children: /*#__PURE__*/ _jsx(Icon, {
97
+ icon: AlignHorizontalDistributeStart
98
+ })
99
+ }),
100
+ /*#__PURE__*/ _jsx(Toolbar.Button, {
101
+ type: "button",
102
+ tooltip: "Align video center",
103
+ active: editor.isActive("videoBlock", {
104
+ align: "center"
105
+ }),
106
+ onClick: onAlignVideoCenter,
107
+ children: /*#__PURE__*/ _jsx(Icon, {
108
+ icon: AlignHorizontalDistributeCenter
109
+ })
110
+ }),
111
+ /*#__PURE__*/ _jsx(Toolbar.Button, {
112
+ type: "button",
113
+ tooltip: "Align video right",
114
+ active: editor.isActive("videoBlock", {
115
+ align: "right"
116
+ }),
117
+ onClick: onAlignVideoRight,
118
+ children: /*#__PURE__*/ _jsx(Icon, {
119
+ icon: AlignHorizontalDistributeEnd
120
+ })
121
+ }),
122
+ /*#__PURE__*/ _jsx(Toolbar.Divider, {}),
123
+ /*#__PURE__*/ _jsx(VideoBlockWidth, {
124
+ onChange: onWidthChange,
125
+ value: parseInt(editor.getAttributes("videoBlock").width)
126
+ })
127
+ ]
128
+ })
129
+ });
130
+ };
131
+ export default VideoBlockMenu;
132
+
133
+ //# sourceMappingURL=VideoBlockMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.tsx"],"sourcesContent":["import { BubbleMenu as BaseBubbleMenu } from \"@tiptap/react\";\nimport { ReactNode, useCallback, useRef } from \"react\";\nimport { Instance, sticky } from \"tippy.js\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n AlignHorizontalDistributeCenter,\n AlignHorizontalDistributeEnd,\n AlignHorizontalDistributeStart,\n} from \"lucide-react\";\nimport { MenuProps } from \"../../../features/menus/types.js\";\nimport { Icon } from \"../../../features/ui/Icon.js\";\nimport { Toolbar } from \"../../../features/ui/Toolbar.js\";\nimport { getRenderContainer } from \"../../../lib/utils/index.js\";\nimport { VideoBlockWidth } from \"./VideoBlockWidth.js\";\n\nexport const VideoBlockMenu = ({ editor, appendTo }: MenuProps): ReactNode => {\n const menuRef = useRef<HTMLDivElement>(null);\n const tippyInstance = useRef<Instance | null>(null);\n\n const getReferenceClientRect = useCallback(() => {\n const renderContainer = getRenderContainer(editor, \"node-videoBlock\");\n const rect =\n renderContainer?.getBoundingClientRect() ||\n new DOMRect(-1000, -1000, 0, 0);\n\n return rect;\n }, [editor]);\n\n const shouldShow = useCallback(() => {\n const isActive = editor.isActive(\"videoBlock\");\n\n return isActive;\n }, [editor]);\n\n const onAlignVideoLeft = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockAlign(\"left\")\n .run();\n }, [editor]);\n\n const onAlignVideoCenter = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockAlign(\"center\")\n .run();\n }, [editor]);\n\n const onAlignVideoRight = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockAlign(\"right\")\n .run();\n }, [editor]);\n\n const onWidthChange = useCallback(\n (value: number) => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockWidth(value)\n .run();\n },\n [editor]\n );\n\n return (\n <BaseBubbleMenu\n editor={editor}\n pluginKey={`videoBlockMenu-${uuid()}`}\n shouldShow={shouldShow}\n updateDelay={0}\n tippyOptions={{\n offset: [0, 8],\n popperOptions: {\n modifiers: [{ name: \"flip\", enabled: false }],\n },\n getReferenceClientRect,\n onCreate: (instance: Instance) => {\n tippyInstance.current = instance;\n },\n appendTo: () => {\n return appendTo?.current;\n },\n plugins: [sticky],\n sticky: \"popper\",\n }}\n >\n <Toolbar.Wrapper shouldShowContent={shouldShow()} ref={menuRef}>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Align video left\"\n active={editor.isActive(\"videoBlock\", { align: \"left\" })}\n onClick={onAlignVideoLeft}\n >\n <Icon icon={AlignHorizontalDistributeStart} />\n </Toolbar.Button>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Align video center\"\n active={editor.isActive(\"videoBlock\", { align: \"center\" })}\n onClick={onAlignVideoCenter}\n >\n <Icon icon={AlignHorizontalDistributeCenter} />\n </Toolbar.Button>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Align video right\"\n active={editor.isActive(\"videoBlock\", { align: \"right\" })}\n onClick={onAlignVideoRight}\n >\n <Icon icon={AlignHorizontalDistributeEnd} />\n </Toolbar.Button>\n <Toolbar.Divider />\n <VideoBlockWidth\n onChange={onWidthChange}\n value={parseInt(editor.getAttributes(\"videoBlock\").width)}\n />\n </Toolbar.Wrapper>\n </BaseBubbleMenu>\n );\n};\n\nexport default VideoBlockMenu;\n"],"names":["BubbleMenu","BaseBubbleMenu","useCallback","useRef","sticky","v4","uuid","AlignHorizontalDistributeCenter","AlignHorizontalDistributeEnd","AlignHorizontalDistributeStart","Icon","Toolbar","getRenderContainer","VideoBlockWidth","VideoBlockMenu","editor","appendTo","menuRef","tippyInstance","getReferenceClientRect","renderContainer","rect","getBoundingClientRect","DOMRect","shouldShow","isActive","onAlignVideoLeft","chain","focus","undefined","scrollIntoView","setVideoBlockAlign","run","onAlignVideoCenter","onAlignVideoRight","onWidthChange","value","setVideoBlockWidth","pluginKey","updateDelay","tippyOptions","offset","popperOptions","modifiers","name","enabled","onCreate","instance","current","plugins","Wrapper","shouldShowContent","ref","Button","type","tooltip","active","align","onClick","icon","Divider","onChange","parseInt","getAttributes","width"],"mappings":";AAAA,SAASA,cAAcC,cAAc,QAAQ,gBAAgB;AAC7D,SAAoBC,WAAW,EAAEC,MAAM,QAAQ,QAAQ;AACvD,SAAmBC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 -0,0 +1,16 @@
1
+ import { Node } from "@tiptap/pm/model";
2
+ import { Editor } from "@tiptap/react";
3
+ import React from "react";
4
+ interface VideoBlockViewProps {
5
+ editor: Editor;
6
+ getPos: () => number;
7
+ node: Node & {
8
+ attrs: {
9
+ src: string;
10
+ };
11
+ };
12
+ updateAttributes: (attrs: Record<string, string>) => void;
13
+ }
14
+ export declare const VideoBlockView: (props: VideoBlockViewProps) => React.JSX.Element;
15
+ export default VideoBlockView;
16
+ //# sourceMappingURL=VideoBlockView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VideoBlockView.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AACxD,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,IAAI,EAAE,IAAI,GAAG;QACX,KAAK,EAAE;YACL,GAAG,EAAE,MAAM,CAAC;SACb,CAAC;KACH,CAAC;IACF,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CAC3D;AAED,eAAO,MAAM,cAAc,UAAW,mBAAmB,sBA+BxD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { NodeViewWrapper } from "@tiptap/react";
3
+ import React, { useCallback, useRef } from "react";
4
+ import { cn } from "../../../lib/utils/index.js";
5
+ export const VideoBlockView = (props)=>{
6
+ const { editor, getPos, node } = props;
7
+ const videoWrapperRef = useRef(null);
8
+ const { src, poster } = node.attrs;
9
+ const wrapperClassName = cn(node.attrs.align === "left" ? "ml-0" : "ml-auto", node.attrs.align === "right" ? "mr-0" : "mr-auto", node.attrs.align === "center" && "mx-auto");
10
+ const onClick = useCallback(()=>{
11
+ editor.commands.setNodeSelection(getPos());
12
+ }, [
13
+ getPos,
14
+ editor.commands
15
+ ]);
16
+ return /*#__PURE__*/ _jsx(NodeViewWrapper, {
17
+ children: /*#__PURE__*/ _jsx("div", {
18
+ className: wrapperClassName,
19
+ style: {
20
+ width: node.attrs.width
21
+ },
22
+ children: /*#__PURE__*/ _jsx("div", {
23
+ contentEditable: false,
24
+ ref: videoWrapperRef,
25
+ children: /*#__PURE__*/ _jsx("video", {
26
+ controls: true,
27
+ className: "block",
28
+ src: src,
29
+ poster: poster,
30
+ title: "",
31
+ onClick: onClick
32
+ })
33
+ })
34
+ })
35
+ });
36
+ };
37
+ export default VideoBlockView;
38
+
39
+ //# sourceMappingURL=VideoBlockView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"sourcesContent":["import { Node } from \"@tiptap/pm/model\";\nimport { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport React, { useCallback, useRef } from \"react\";\nimport { cn } from \"../../../lib/utils/index.js\";\n\ninterface VideoBlockViewProps {\n editor: Editor;\n getPos: () => number;\n node: Node & {\n attrs: {\n src: string;\n };\n };\n updateAttributes: (attrs: Record<string, string>) => void;\n}\n\nexport const VideoBlockView = (props: VideoBlockViewProps) => {\n const { editor, getPos, node } = props;\n const videoWrapperRef = useRef<HTMLDivElement>(null);\n const { src, poster } = node.attrs;\n\n const wrapperClassName = cn(\n node.attrs.align === \"left\" ? \"ml-0\" : \"ml-auto\",\n node.attrs.align === \"right\" ? \"mr-0\" : \"mr-auto\",\n node.attrs.align === \"center\" && \"mx-auto\"\n );\n\n const onClick = useCallback(() => {\n editor.commands.setNodeSelection(getPos());\n }, [getPos, editor.commands]);\n\n return (\n <NodeViewWrapper>\n <div className={wrapperClassName} style={{ width: node.attrs.width }}>\n <div contentEditable={false} ref={videoWrapperRef}>\n <video\n controls\n className=\"block\"\n src={src}\n poster={poster}\n title=\"\"\n onClick={onClick}\n />\n </div>\n </div>\n </NodeViewWrapper>\n );\n};\n\nexport default VideoBlockView;\n"],"names":["NodeViewWrapper","React","useCallback","useRef","cn","VideoBlockView","props","editor","getPos","node","videoWrapperRef","src","poster","attrs","wrapperClassName","align","onClick","commands","setNodeSelection","div","className","style","width","contentEditable","ref","video","controls","title"],"mappings":";AACA,SAAiBA,eAAe,QAAQ,gBAAgB;AACxD,OAAOC,SAASC,WAAW,EAAEC,MAAM,QAAQ,QAAQ;AACnD,SAASC,EAAE,QAAQ,8BAA8B;AAajD,OAAO,MAAMC,iBAAiB,CAACC;IAC7B,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGH;IACjC,MAAMI,kBAAkBP,OAAuB;IAC/C,MAAM,EAAEQ,GAAG,EAAEC,MAAM,EAAE,GAAGH,KAAKI,KAAK;IAElC,MAAMC,mBAAmBV,GACvBK,KAAKI,KAAK,CAACE,KAAK,KAAK,SAAS,SAAS,WACvCN,KAAKI,KAAK,CAACE,KAAK,KAAK,UAAU,SAAS,WACxCN,KAAKI,KAAK,CAACE,KAAK,KAAK,YAAY;IAGnC,MAAMC,UAAUd,YAAY;QAC1BK,OAAOU,QAAQ,CAACC,gBAAgB,CAACV;IACnC,GAAG;QAACA;QAAQD,OAAOU,QAAQ;KAAC;IAE5B,qBACE,KAACjB;kBACC,cAAA,KAACmB;YAAIC,WAAWN;YAAkBO,OAAO;gBAAEC,OAAOb,KAAKI,KAAK,CAACS,KAAK;YAAC;sBACjE,cAAA,KAACH;gBAAII,iBAAiB;gBAAOC,KAAKd;0BAChC,cAAA,KAACe;oBACCC,QAAQ;oBACRN,WAAU;oBACVT,KAAKA;oBACLC,QAAQA;oBACRe,OAAM;oBACNX,SAASA;;;;;AAMrB,EAAE;AAEF,eAAeX,eAAe"}
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ export type VideoBlockWidthProps = {
3
+ onChange: (value: number) => void;
4
+ value: number;
5
+ };
6
+ export declare const VideoBlockWidth: React.MemoExoticComponent<({ onChange, value }: VideoBlockWidthProps) => React.JSX.Element>;
7
+ //# sourceMappingURL=VideoBlockWidth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VideoBlockWidth.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockWidth.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,eAAe,kDACJ,oBAAoB,uBA+B3C,CAAC"}